$(function() {
	admin.deliveryOrder.init();
});
Namespace('admin.deliveryOrder', {
	init : function() {
		easyui.util.initDatagrid('#datagrid', {
			onDblClickRow : function() {
				var row = $('#datagrid').datagrid('getSelected');
				admin.deliveryOrder.detail(row.id);
			}
		});
	},
	query : function() {
		if (!$('#query-form').form('validate'))
			return;
		var data = $('#query-form').form('jsonObject');
		$('#datagrid').datagrid('load', data);
	},
	detail:function(id) {
		if(id==null) {
			top.showInfo('请选择需要修改的记录!');
			return;
		}
		top.addTab(id,'订单详情', contextPath+'/delivery/order/detail?id=' + id);
	},
	inStorage:function(oid) {
		if (oid != null) {
			if (confirm("确定货物已收到?")) {
				var data = {"id":oid};
	            var url = contextPath + '/delivery/order/inStorage';
				$.post(url, data, function (result) {
					if (result.code == 1) {
						top.showInfo('入库成功');
					} else {
						top.showInfo(result.msg);
					}
				});
			}
		}
	}
});